// Raf Lempens & Bjorn Schobben
#include "TurnStep.h"

TurnStep::TurnStep(): turnableInterface(0), turnableObject(0)
{
}

TurnStep::TurnStep(const TurnStep& rhs): turnableInterface(rhs.turnableInterface), turnableObject(rhs.turnableObject), turnDirection(rhs.turnDirection)
{
}

TurnStep::~TurnStep()
{
}

void TurnStep::Execute()
{
	
	if (turnableInterface && turnableObject)
	{
		if (turnDirection.IsWest())
			turnableInterface->TurnLeft();
		else if (turnDirection.IsEast())
			turnableInterface->TurnRight();

		gameBoard->Update(turnableObject);
	}
}

void TurnStep::SetObject(GameObject* object, Turnable* turnable)
{
	turnableInterface = turnable;
	turnableObject = object;
}

void TurnStep::SetDirection(const Direction& direction)
{
	turnDirection = direction;
}

void TurnStep::SetBoard(Board* board)
{
	gameBoard = board;
}


TurnStep* TurnStep::Clone() const
{
	return new TurnStep(*this);
}
